#define _CRT_SECURE_NO_WARNINGS
//https://www.nowcoder.com/practice/4b91205483694f449f94c179883c1fef?tpId=60&&tqId=29483&rp=1&ru=/activity/oj&qru=/ta/tsing-kaoyan/question-ranking
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>

typedef struct BinomialTree
{
    char data;
    struct BinomialTree* left;
    struct BinomialTree* right;
}BTNode;

void BuyNode(BTNode* root, int* str, int* pi)
{
    if (str[*pi] == '#')
        root = NULL;
    BTNode* NewNode = (BTNode*)malloc(sizeof(BTNode));
    if (NewNode == NULL)
    {
        perror("malloc fail");
        exit(-1);
    }
    root->data = str[*pi];

    BuyNode(root->left, str, pi);
    BuyNode(root->right, str, pi);

}
BTNode* CreatTree(char* str, int* pi)
{

    if (str[*pi] == '#')
    {
        (*pi)++;
        return NULL;
    }
    BTNode* NewNode = (BTNode*)malloc(sizeof(BTNode));
    if (NewNode == NULL)
    {
        perror("malloc fail");
        exit(-1);
    }
    NewNode->data = str[*pi];
    (*pi)++;

    NewNode->left = CreatTree(str, pi);
    NewNode->right = CreatTree(str, pi);

    return NewNode;
}

void Inoder(BTNode* root)
{
    if (root == NULL)
        return;

    Inoder(root->left);
    printf("%c ", root->data);
    Inoder(root->right);
}
int main()
{
    char str[100];
    scanf("%s", str);
    int i = 0;
    BTNode* BT = CreatTree(str, &i);
    Inoder(BT);
}